package com.example.common;

import lombok.Data;

/**
 * @BelongsProject: pms
 * @BelongsPackage: com.wh.common
 * @Author: LJ
 * @CreateTime: 2020-07-16 16:02
 * @Description:
 */
@Data
public class ServiceResponse<T> {

    private Integer status;
    private T data;
    private String msg;
    private String token;

    public ServiceResponse() {
    }

    public ServiceResponse(Integer status) {
        this.status = status;
    }

    public ServiceResponse(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public ServiceResponse(Integer status, T data) {
        this.status = status;
        this.data = data;
    }

    public static ServiceResponse createSuccess() {
        return new ServiceResponse(0);
    }

    public static ServiceResponse createSuccess(String msg) {
        return new ServiceResponse(0, msg);
    }

    public static <T> ServiceResponse createSuccess(T data) {
        return new ServiceResponse(0, data);
    }

    public static ServiceResponse createError() {
        return new ServiceResponse(1);
    }

    public static ServiceResponse createError(String msg) {
        return new ServiceResponse(1, msg);
    }

    public static ServiceResponse createError(Integer status, String msg) {
        return new ServiceResponse(status, msg);
    }
}
